#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/12/27 16:03
# @Author: 周健
# @Email: 907614893@qq.com
# @File：search_page.py
from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage


class SearchPage(BasePage):
    huoguo_locator = (By.ID,'com.gfeng.daydaycook:id/historyTv')
    work_locator = (By.XPATH,'//android.widget.TextView[@text=\"作品\"]')
    user_locator= (By.XPATH,'//android.widget.TextView[@text=\"用户\"]')
    cancel_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/cancelTv\"]')
    hot_locator = (By.XPATH,'//android.view.ViewGroup[@resource-id=\"com.gfeng.daydaycook:id/hotFlow\"]/android.widget.FrameLayout[1]/android.widget.TextView[1]')

    # 点击火锅
    def click_huoguo(self):
        self.driver.find_element(*self.huoguo_locator).click()
    # 点击作品
    def click_work(self):
        self.driver.find_element(*self.work_locator).click()
    # 点击用户
    def click_user(self):
        self.driver.find_element(*self.user_locator).click()
    # 点击取消
    def click_cancel(self):
        self.driver.find_element(*self.cancel_locator).click()
    # 获取精选页面activity
    def get_jx_activity(self):
        return self.driver.current_activity
    # 点击热门搜索中的蛋糕
    def click_hot(self):
        self.driver.find_element(*self.hot_locator).click()